package com.example.day_0813_103.slice;

import com.example.day_0813_103.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Text;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;

import java.util.HashSet;
import java.util.Set;

public class four_AbilitySlice extends AbilitySlice {
    private static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP,0x00201,"MY_TAG");

    @Override
    public void onStart(Intent intent) {
        HiLog.info(LABEL,"这里是 four_AbilitySlice 的 onStart");

        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_four_);

        Text text = (Text) findComponentById(ResourceTable.Id_four_t_two);
        text.setText(intent.getStringParam("value"));

        Set<String> set = intent.getEntities();
        for (String str: set) {
            HiLog.info(LABEL,str);
        }

        Button button = (Button) findComponentById(ResourceTable.Id_four_btn_one);
        button.setClickedListener(component -> terminate());
    }
//    public void myablity(String component) {
//        Intent it = new Intent();
//        Operation operation = new Intent.OperationBuilder()
//                .withDeviceId("")
//                .withBundleName("com.example.day_0813_103")
//                .withAbilityName(component)
//                .build();
//        it.setOperation(operation);
//        it.setParam("value","你最强！");
//        startAbilityForResult(it,456);
//    }

    @Override
    public void onActive() {
        super.onActive();
        HiLog.info(LABEL,"这里是 four_AbilitySlice 的 onActive");

    }

    @Override
    protected void onInactive() {
        HiLog.info(LABEL,"这里是 four_AbilitySlice 的 onInactive");
        super.onInactive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
        HiLog.info(LABEL,"这里是 four_AbilitySlice 的 onForeground");

    }
}
